<!doctype html>
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<title>微社区</title>
<link href="../../css/newStyle.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/gbRst.js"></script>
<script type="text/javascript" src="../../js/utils.js"></script>
<script type="text/javascript" src="../../js/openId.js"></script>
<script type="text/javascript" src="../../js/ajaxfileupload.js"></script> 
<script type="text/javascript" src="../../js/header&footer.js"></script>
<!-- <script type="text/javascript" src="../../js/carService.js"></script>
 --><script type="text/javascript" src="../../js/doubleDate2.0.js"></script>
<script type="text/javascript" src="../../js/check.js"></script>
<!-- <script type="text/javascript" src="../../js/ImageBrowsing.js"></script>
 -->		<script type="text/javascript" src="../../js/qmsk-1.2.js"></script>
		<script type="text/javascript" src="../../js/openId.js"></script>
		<script type="text/javascript" src="../../js/communityTheme.js"></script>
<script type="text/javascript">
var imageNum =1;
var memberId = 0;
var memberName= "游客";
var imageUrl = "../../images/userImg.jpg";
var title =null;
$(function(){
	var winHei=$(window).height()+80;
	$(".proDetails").css("top",winHei+"px");//加载时到屏幕最下方
	$(".proDetails .placeTit").click(function(){
		$(".proDetails").animate({"top":winHei+"px"},function(){
			$("body").css("overflow-y","scroll");	
		});	
	});//点击隐藏
	$(".giveTxt").parent("li").click(function(){
		$(".proDetails").animate({"top":0},function(){
			getTitle();
			$("body").css("overflow-y","hidden");
		});
	})//点击显示
//赞
	 var community =  getCommunity(1)
	 if(IsNotEmpty(community)&&community.state==0){
		 $("#communityImage").attr("src",getHtmlString(getHeadIndexValue(0, community, "imageUrl")));
		 $("#communityTitle").html(getHtmlString(getHeadIndexValue(0, community, "title")))
		 $("#communityNotenums").html(getHtmlString(getHeadIndexValue(0, community, "notenums")))
		 $("#communityContent").html(getHtmlString(getHeadIndexValue(0, community, "content")))
		 $("#communityNums").html(getHtmlString(getHeadIndexValue(0, community, "num")))
	 }
	var  member=_findInfo("../../../member/find/shopId/"+getShopId()+"/openId/"+_openId, null)
	if(IsNotEmpty(member)&&member.state==0&&member.result.data.length>0){
		memberId=getHtmlString(getHeadIndexValue(0, member, "memberId"));
		memberName=getHtmlString(getHeadIndexValue(0, member, "CustomerName"));
		var  ime=getHtmlString(getHeadIndexValue(0, member, "imageUrl"));
		if(IsNotEmpty(ime)){
			imageUrl = ime;
		}
	}
	
	//getCommunity()
 	getNotes()
 	restForm()
})
function getNotes(){
	 new qmsk.SiglePinterest({
			url : '../../../notes/find/noteList', // 请求地址，插件会自动在 url 后追加 /n/n
			initPage : 1, // 首次加载页数
			size : 10, // 每次加载数量，即每页的大小
			success : printDataToPage, // 成功回调
			valves : 100 ,//当滚动条距离底部该像素的时候加载
			data:{'shopId':_shopId,'memberId':memberId},
			loading : addRefresh2,
			loaded : delRefresh

		});
}

function parise(id){
	if(IsEmpty(memberId)){
		alert("您还不是会员")

		return false;
	}
 	if(!$("#parise_"+id).hasClass("wonderful")){
 		var heads = new Array("noteId","memberId")
 		var datas = new Array(id,memberId)
 		var params= _getJsonParseInsertStr(heads, datas);
 		var dt = _insertInfoNoSucceedMessage("../../../notes/insert/insertParise", {'data':params})
 		if(IsNotEmpty(dt)&&dt.state==0){
 	 		var num= getHtmlInt($("#parise_"+id).next("b").html()) ;	
 	 		num++;
 	 		$("#parise_"+id).next("b").html(num)
 	 		$("#parise_"+id).addClass("wonderful");	
 		}
		}
		
		
	
}

function printDataToPage(dt){
	var urlThml="&openId="+_openId+"&shopId="+_shopId
	for(var i = 0;i<dt.row;i++){
		var imgUrl = dt.getValue("imageUrl",i)
		if(IsEmpty(imgUrl)){
			imgUrl = "../../images/userImg.jpg";
		}
		var htm="<div class=\"comeGift\"><header><dl><dt><img src=\""+imgUrl+"\"></dt><dd><strong>"+dt.getValue("customerName",i)+"</strong><br><time>"+dt.getValue("createdTime",i)+"</time></dd></dl><aside><b></b><span>"+dt.getValue("memo",i)+"</span><span class=\"red\"></span></aside></header><section>"
		var id= dt.getValue('id',i)
		var imagesList= _findInfo('../../../notes/find/imageList', {'id':id})
		if(IsNotEmpty(imagesList)&&imagesList.state==0){
			var x = imagesList.result.data.length
		if(x>0){
			
		htm+="<figure data-count=\""+x+"张图片\"><div>";
		for(var j=0;j<x;j++){
		htm+="<img src=\""+getHtmlInt(getHeadIndexValue(j, imagesList, "imageUrl"))+"\" data-src=\""+getHtmlInt(getHeadIndexValue(j, imagesList, "imageUrl"))+"\" data-gid=\"g0\" onload=\"preViewImg(this, event);\">"
		}
		htm+="</div></figure>";
		}	

		}
		
		htm+="<h4 class=\"title abbTit\">"+ dt.getValue("title",i)+"</h4>"+
		"<p class='abb'>"+replace_em (dt.getValue("content",i))+"</p>"+
		"<a href=\"discuss.html?id="+dt.getValue("id",i)+urlThml+"\">查看全文</a></section><footer><ul><li><span class=\"look\"></span><b>"+dt.getValue("nums",i)+"</b></li><li onClick=\"redirectUrl('discuss.html?id="+dt.getValue("id",i)+urlThml+"')\"><span class=\"reply\"></span><b>"+dt.getValue("discussNums",i)+"</b></li>"
		var mId = dt.getValue("memberId",i)
		if(IsNotEmpty(mId)){
		htm+="<li id='li_"+dt.getValue("id",i)+"' onclick='parise("+dt.getValue("id",i)+")'><span id='parise_"+dt.getValue("id",i)+"' class=\"good wonderful\"></span><b>"+dt.getValue("praiseNums",i)+"</b></li></ul></footer></div>";
		}else{
			htm+="<li id='li_"+dt.getValue("id",i)+"' onclick='parise("+dt.getValue("id",i)+")'><span id='parise_"+dt.getValue("id",i)+"' class=\"good\"></span><b>"+dt.getValue("praiseNums",i)+"</b></li></ul></footer></div>";
		}
		$("#info").append(htm)
	}
	

	
}

function  doAfterLoadImage(){
	$("#upload_"+imageNum).hide()
	$("#delImg_"+imageNum).show();
	imageNum++;
	var htm="<div class='showDel' id='img_"+imageNum+"' ><input type='hidden' class='imageUrl' id='imageUrl_"+imageNum+"'> <i class=\"delImg\" id='delImg_"+imageNum+"' onclick = \"delImg("+imageNum+")\" style='display:none;'></i><span class=\"addImg\" id=\"image_"+imageNum+"\"><img  style='width:34px;height:34px' src=\"../../images/addImg.jpg\"></span><input type=\"file\" id=\"upload_"+imageNum+"\" name=\"upload_"+imageNum+"\"  onchange=\"uploadImage('upload_"+imageNum+"')\"  class=\"file\"></div>"
	if(imageNum==7){
		$("#showNum").hide();
	}else{
		
	$("#imageAll").append(htm)
	}
}

function delImg(i){
	$("#img_"+i).remove();
}

function addInfo(){
	if(IsEmpty(memberId)||memberId==0){
		alert("您还不是会员")

		return false;
	}
	var memo=$("#memo").val();
	var title= $("#title").val();
	var content =$("#saytext").val();
	if(!checkNull(memo, "行驶里程", "memo")||!checkNull(title, "标题", "title")||!checkNull(content, "内容", "content")){
		return false;
	}
	var heads = new Array("title","content","customerId","customerName","memo","shopId","communityId","openId")
	var datas = new Array(title,content,memberId,memberName,memo,_shopId,1,_openId)
	var params= _getJsonParseInsertStr(heads, datas);
	var parser2 = new Object();
	var jsonParserStr2 = null;
	$(".imageUrl").each(function(){
		var imageUrl = $(this).val()
		var head=new Array("imageUrl")
		 var data=new Array(imageUrl)
		if (IsNotEmpty(imageUrl)){
			addToParser(head, data, "add" , parser2);
			jsonParserStr2 =  JSON.stringify(parser2);
		}
	})
	addLoading();
	var dt=_insertInfoNoSucceedMessage("../../../notes/insert/insertInfo2", {'data':params,'image':jsonParserStr2});
	if(IsNotEmpty(dt)&&dt.state==0){
		delLoading()
		alert("发帖成功")
		window.location.reload()
	}else{
		delLoading()
		alert("发帖失败")
	}
	
	
}


function uploadImage(id){
	if($("#"+id).val().length>0){
		addLoadingImage()
		$.ajaxFileUpload({
		url :'../../../notes/upload/image/1?ids=22',
		secureuri : false,
		fileElementId : id,
		dataType : 'json',
		success : function(data){
			if (data.state == 0) {
			var imgUrl=getHtmlString(getHeadIndexValue(0, data, "imageUrl"));
			$("#img_"+imageNum+" img").attr("src",imgUrl)
			$("#imageUrl_"+imageNum).val(imgUrl)
 			doAfterLoadImage();
			}else if(data.state == 1){
				alert("图片上传失败")
/* 				deleteNotes(id);
 */			}
			delLoading()
		},
		error : function(data) {
			deleteNotes(id);
			art.dialog({fixed:true, lock: true,content:"图片上传失败",icon:'error',ok:true});	
			return false;
		}
	});
	}
}

	function restForm(){
		$("#title").val("");
		$("#saytext").val("");
		$("#memo").val("");
		imageNum = 1;
		var htm="<div class='showDel' id=\"img_1\"><input type='hidden' class='imageUrl' id='imageUrl_1'> <i class=\"delImg\" id=\"delImg_1\" onclick=\"delImg(1)\" style=\"display: none;\"></i><span class=\"addImg\" id=\"image_1\"><img style='width:34px;height:34px' src=\"../../images/addImg.jpg\"></span><input type=\"file\" id=\"upload_"+imageNum+"\" name=\"upload_"+imageNum+"\" onchange=\"uploadImage('upload_"+imageNum+"')\" class=\"file\"></div>"
		$("#imageAll").html(htm)
		$("#upload_1").attr("disabled",false)
	}
	
	function goSy(){
		var htm = "?openId="+getOpenId()+"&shopId="+getShopId();
		 redirectUrl('comeOver.html'+htm)
	}
	function goMine(){
		var htm = "?openId="+_openId+"&shopId="+_shopId;
		redirectUrl('mineData.html'+htm)
	}
	
	function getTitle(){
		if(memberId!=0&&IsEmpty(title)){
			var dt = _findInfo("../../../notes/find/findLastMeglie", {'memberId':memberId})
			if(dt.state==0){
				$("#memo").val(getHtmlString(getHeadIndexValue(0, dt, "memo")));
			}
		}
	}

</script>
<script type="text/javascript" src="../../js/jquery.qqFace.js"></script>
<script type="text/javascript">
$(function(){
	$('.emotion').qqFace({
		assign:'saytext', //给那个控件赋值
		path:'../../images/face/'	//表情存放的路径
	});
});
//替换表情
</script>
</head>

<body>
<div class="proDetails">
 <div class="placeTit"><div class="back"></div>发帖</div>
    <div class="det"><p>行驶里程<span class="red">*</span><br><input id="memo" type="text" class="txt"></p><p>标题<span class="red">*</span><br><input type="text" id="title" class="txt"></p>
<div class="showFaceTxt">
      <textarea class="saytext" id="saytext"></textarea>
      <div class="com_form">
        <p><span class="emotion"></span> </p>
      </div>
    </div>
    </div>
    <div class="uploadImg">
    	<div id="imageAll" style="display:inline;">
<!--     	<label id="img_1"><i class="delImg" id="delImg_1" onclick="delImg(1)" style="display: none;"></i><span class="addImg" id="image_1"><img src="../../images/addImg.jpg"></span><input type="file" id="upload_1" name="upload_1" class="file" >
 	</label>-->    
    	</div>
    	
        <aside id="showNum" class="tips">最多可上传6张图片</aside>
    </div>
    <div class="give">
        <input type="button" value="发帖" class="giveBtn" onclick="addInfo()">
    </div>
    <!--qq表情--> 
    <!--<div id="show"></div>
     <div class="comment">
        <div class="com_form">
        	<textarea class="input" id="saytext" name="saytext"></textarea>
        	<p><span class="emotion">表情</span><input type="button" class="sub_btn" value="提交"></p>
        </div>
     </div>-->
      </div>
  
<div class="wrapper" style="padding-bottom:46px;">
  <header class="comeAward">
    <div class="logo"><img id="communityImage" src=""></div>
    <h1 id="communityTitle"></h1>
      <div class="communityDet" id="communityContent"></div>
    <div class="tags"><span class="book"></span><b id="communityNotenums">0</b>帖子<span class="person"></span><b id="communityNums">0</b>访问</div>
  </header>
  <div class="container" id="info">
    <!-- <div class="comeGift">
      <header>
        <dl>
          <dt><img src="../../images/userImg.jpg"></dt>
          <dd><strong>冰</strong><br>
            <time>2012-03-20 12:00</time>
          </dd>
        </dl>
        <aside><b></b><span>宝马</span><span class="red">3000</span>公里</aside>
      </header>
      <section>
      	
        <h4 class="title abbTit">绵阳主播绵阳主播绵阳主播绵阳主播绵阳主播绵阳主播</h4>
        <p class="abb">价位哦IF奖陪我i减肥品味EFI金额为盲从口味快递费金额为盲从口味快递费金额为盲从口味快递费金额为盲从口味快递费，建文件fine我veowsiv</p>
        <a href="discuss.html">查看全文</a></section>
      <footer>
        <ul>
          <li><span class="look"></span><b>10</b></li>
          <li onClick="redirectUrl('discuss.html')"><span class="reply"></span><b>20</b></li>
          <li><span class="good"></span><b>10</b></li>
        </ul>
      </footer>
    </div>
    over
    <div class="comeGift">
      <header>
        <dl>
          <dt><img src="../../images/userImg.jpg"></dt>
          <dd><strong>冰</strong><br>
            <time>2012-03-20 12:00</time>
          </dd>
        </dl>
        <aside><b></b><span>宝马</span><span class="red">3000</span>公里</aside>
      </header>
      <section>
      	<figure data-count="6张图片">
        	<div>
        	<img src="../../images/host1.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
        	<img src="../../images/host2.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
        	<img src="../../images/host3.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
        	<img src="../../images/host4.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
        	<img src="../../images/host5.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
        	<img src="../../images/host6.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
            </div>
        </figure>
        <h4 class="title abbTit">绵阳主播</h4>
        <p class="abb">价位哦IF奖陪我i减肥品味EFI金额为盲从口味快递费，建文件fine我veowsiv</p>
        <a href="discuss.html">查看全文</a></section>
      <footer>
        <ul>
          <li><span class="look"></span><b>0</b></li>
          <li><span class="reply" onClick="redirectUrl('discuss.html')"></span><b>20</b></li>
          <li><span class="good"></span><b>10</b></li>
        </ul>
      </footer>
    </div> -->
  </div>
  <footer class="giftBottom">
    <ul>
      <li onClick="goSy()"><span class="home"></span>首页</li>
      <li><span class="giveTxt"></span>发帖</li>
      <li onClick=" goMine()"><span class="mineHome"></span>我的</li>
    </ul>
  </footer>
</div>
</body>
</html>
